Merge "GlobalFunctions: Remove usage of `wfArrayFilter` & `wfArrayFilterByKey`"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 27 Apr 2019 07:21:46 +0000 (07:21 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 27 Apr 2019 07:21:46 +0000 (07:21 +0000)
includes/GlobalFunctions.php
tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php [deleted file]

index 2497b0f..118a617 100644 (file)
@@ -140,32 +140,6 @@ function wfArrayDiff2_cmp( $a, $b ) {
        }
 }
 
-/**
- * @deprecated since 1.32, use array_filter() with ARRAY_FILTER_USE_BOTH directly
- *
- * @param array $arr
- * @param callable $callback Will be called with the array value and key (in that order) and
- *   should return a bool which will determine whether the array element is kept.
- * @return array
- */
-function wfArrayFilter( array $arr, callable $callback ) {
-       wfDeprecated( __FUNCTION__, '1.32' );
-       return array_filter( $arr, $callback, ARRAY_FILTER_USE_BOTH );
-}
-
-/**
- * @deprecated since 1.32, use array_filter() with ARRAY_FILTER_USE_KEY directly
- *
- * @param array $arr
- * @param callable $callback Will be called with the array key and should return a bool which
- *   will determine whether the array element is kept.
- * @return array
- */
-function wfArrayFilterByKey( array $arr, callable $callback ) {
-       wfDeprecated( __FUNCTION__, '1.32' );
-       return array_filter( $arr, $callback, ARRAY_FILTER_USE_KEY );
-}
-
 /**
  * Appends to second array if $value differs from that in $default
  *
diff --git a/tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php b/tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php
deleted file mode 100644 (file)
index bc930be..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-/**
- * @group GlobalFunctions
- * @covers ::wfArrayFilter
- * @covers ::wfArrayFilterByKey
- */
-class WfArrayFilterTest extends MediaWikiTestCase {
-       public function testWfArrayFilter() {
-               $this->hideDeprecated( 'wfArrayFilter' );
-               $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
-               $filtered = wfArrayFilter( $arr, function ( $val, $key ) {
-                       return $key !== 'b';
-               } );
-               $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered );
-
-               $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
-               $filtered = wfArrayFilter( $arr, function ( $val, $key ) {
-                       return $val !== 2;
-               } );
-               $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered );
-
-               $arr = [ 'a', 'b', 'c' ];
-               $filtered = wfArrayFilter( $arr, function ( $val, $key ) {
-                       return $key !== 0;
-               } );
-               $this->assertSame( [ 1 => 'b',  2 => 'c' ], $filtered );
-       }
-
-       public function testWfArrayFilterByKey() {
-               $this->hideDeprecated( 'wfArrayFilterByKey' );
-               $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
-               $filtered = wfArrayFilterByKey( $arr, function ( $key ) {
-                       return $key !== 'b';
-               } );
-               $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered );
-
-               $arr = [ 'a', 'b', 'c' ];
-               $filtered = wfArrayFilterByKey( $arr, function ( $key ) {
-                       return $key !== 0;
-               } );
-               $this->assertSame( [ 1 => 'b',  2 => 'c' ], $filtered );
-       }
-}